home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <dos.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include"include\L_Bitmap.h"
- #include"include\L_error.h"
- #include"include\L_toolap.h"
-
- #define OK 1
- #define BAD_COMMAND -2
- #define TARGAOLD 1
- #define VGA 2
-
- int mode,page;
- int Width=0,Height=0,Xorigin=-1,Yorigin=-1;
- int time=0;
- int video=VGA;
- int device_bits;
- char infile[400];
-
-
- main(int argc, char *argv[])
- {
- FILE *Stream;
- FILEINFO FileInformation;
- char command[400], commandln[400];
- struct find_t file;
- int result;
- int i;
- char string[400], pathname[400];
- int lines=0;
- int error;
- int first_option = 0;
- int position, position1, kk;
- char path[200];
-
- strcpy(path, argv[0]);
-
- L_SetDecompressFormatJTIF();
- L_SetDecompressFormatJFIFCMP();
-
-
- for (i = strlen(path)-1; i > 0; i--)
- {
- if (path[i] == '\\' || path[i] == ':')
- break;
- }
- path[i+1] = 0;
- i=0;
-
- #if !defined(FOR_386)
- /**** load the fixed palette table to memory ****/
- if ( L_LoadFixedPalette(path) != SUCCESS)
- {
- puts("Error: cannot load FIXEDPAL.DAT file.\n");
- putch(7);
- exit(0);
- }
- #endif
-
- L_GetVideoMode(&mode,&page);
-
- L_SetCheckStatus(NO_CHECK);
-
- if(argc<=1)
- {
- printf("\n LEADTOOLS DOS EVAL copy V 2.2\n");
- printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
- printf(" 8701 Mallard Creek Rd.\n");
- printf(" Charlotte NC 28262 Tel# (704)549-5532\n\n");
- printf("\nDOS 32 - File to screen software deompression utility Version 3.4\n");
- printf("\nThis version has a limit of image width not to exceed 1500 pixels.\n");
- L_SleepKey(2);
- printf("USAGE: LSHOW <@macro file name>\n");
- printf("or LSHOW <source file> [/option1] [/option2] [/option3] [/option4]\n");
- printf(" [/option5] [/option6]\n\n");
- printf("<source file> is any LEAD, JFIF, or JTIF compressed file formats\n");
- printf("<source file> is any LEAD, JFIF, or JTIF compressed file formats\n");
- printf(" or TGA, TIFF, or BMP file formats\n");
-
- #ifdef TARGA
- printf("[option1] /TA for TARGA16, TARGA24, or TARGA32\n");
- #else
- printf("[option1] /TA for TARGA+16, TARGA+32, TARGA+64\n");
- #endif
- printf(" or /V320 display to FAST SUPER VGA 320X200\n");
- printf(" /V640 display to FAST SUPER VGA 640X480\n");
- printf(" /V800 display to FAST SUPER VGA 800X600\n");
- printf(" /V1024 display to FAST SUPER VGA 1024X768\n");
- printf("[option2] /W# the New Width of the image displayed on the screen\n");
- printf("[option3] /H# the New Height of the image displayed on the screen\n");
- printf("[option4] /T# number of seconds to keep image displayed on the screen\n");
- printf("[option5] /X# the X (horizontal) position of the image displayed on the screen\n");
- printf("[option6] /Y# the Y (vertical) position of the image displayed on the screen\n\n");
- printf("EXAMPLE LSHOW *.* /W300 /H200 /T4 /X20 /Y20\n");
- printf("Will display all image files to the VGA/SuperVGA screen at the best resolution\nfor the selected image file\n");
- exit(0);
- }
- strcpy(string,argv[1]);
- get_pathname(argv[1], pathname);
- if(argv[1][0]=='@')
- {
- i=0;
- while(string[i])
- {
- pathname[i]=string[i+1];
- i++;
- }
- pathname[i]= '\0';
- if(Stream=fopen(pathname,"r"))
- {
- while(fgets(commandln, 400, Stream) != NULL)
- {
- Width = 0; Height = 0;
- Xorigin = 0; Yorigin = 0;
- first_option = 0;
- position = 0;
- while(sscanf(commandln+position,"%s",command)!=EOF)
- {
- position1 = strlen(command);
- if( (position1 == 0) || (command[0]=='#') )
- break;
- position = position + position1;
- strupr(command);
- if(command[0]=='/')
- {
- get_value(command+1);
- first_option = 1;
- }
- else if (first_option == 0)
- {
-
- strcpy(infile,command);
- getfilename(infile);
- first_option = 1;
- }
- else
- {
- L_SetVideoMode(mode,page);
- printf("Error: invalid macro line %s\n",commandln);
- exit(0);
- }
- for (kk = position; kk < strlen(commandln); kk++)
- {
- if (commandln[kk] == 0x0d || commandln[kk] == 0x0a)
- {
- position1 = 0;
- break;
- }
-
- if (commandln[kk] > 32)
- break;
- }
-
- position = kk;
- if (position1 == 0)
- break;
- }
- if(infile[0]!='\0')
- {
-
- if(video==VGA)
- {
- L_GetVideoDeviceBits(&device_bits);
- if (L_FileInfo(infile, &FileInformation)==SUCCESS)
- {
- if( FileInformation.Format == FILE_TGA)
- {
- #if !defined(FOR_386)
- if(FileInformation.BitsPerPixel > 8)
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- L_SetVideoMode(mode,page);
- puts("Error: cannot load FIXED.DAT file.\n");
- putch(7);
- exit(0);
- }
- #endif
-
- error=L_ShowTGAScreen(infile,Width,Height,Xorigin,Yorigin);
-
- #if !defined(FOR_386)
- if (FileInformation.BitsPerPixel > 8 && device_bits == 8 )
- L_FreeRGBFixedPalette();
- #endif
-
- }
- else if( FileInformation.Format == FILE_TIF)
- {
- #if !defined(FOR_386)
- if(FileInformation.BitsPerPixel > 8)
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- L_SetVideoMode(mode,page);
- puts("Error: cannot load FIXED.DAT file.\n");
- putch(7);
- exit(0);
- }
- #endif
-
- error=L_ShowTIFScreen(infile,Width,Height,Xorigin,Yorigin);
- #if !defined(FOR_386)
- if (FileInformation.BitsPerPixel > 8 && device_bits == 8 )
- L_FreeRGBFixedPalette();
- #endif
- }
- else if( (FileInformation.Format == FILE_BMP) || (FileInformation.Format == FILE_OS2) )
- {
- #if !defined(FOR_386)
- if(FileInformation.BitsPerPixel > 8)
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- L_SetVideoMode(mode,page);
- puts("Error: cannot load FIXED.DAT file.\n");
- putch(7);
- exit(0);
- }
- #endif
-
- error=L_ShowBMPScreen(infile,Width,Height,Xorigin,Yorigin);
-
- #if !defined(FOR_386)
- if (FileInformation.BitsPerPixel > 8 && device_bits == 8 )
- L_FreeRGBFixedPalette();
- #endif
-
- }
- else if( FileInformation.Format == FILE_PCX)
- {
- #if !defined(FOR_386)
- if(FileInformation.BitsPerPixel > 8)
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- L_SetVideoMode(mode,page);
- puts("Error: cannot load FIXED.DAT file.\n");
- putch(7);
- exit(0);
- }
- #endif
-
- error=L_ShowPCXScreen(infile,Width,Height,Xorigin,Yorigin);
-
- #if !defined(FOR_386)
- if (FileInformation.BitsPerPixel > 8 && device_bits == 8 )
- L_FreeRGBFixedPalette();
- #endif
-
- }
- else if( FileInformation.Format == FILE_GIF)
- {
- error=L_ShowGIFScreen(infile,Width,Height,Xorigin,Yorigin);
- }
- else if( (FileInformation.Format == FILE_CMP) || (FileInformation.Format == FILE_JTIF)
- || ( FileInformation.Format == FILE_JFIF) )
- {
- #if !defined(FOR_386)
- error=L_DecompressVGAScreenFP(infile, Width, Height, Xorigin,Yorigin);
- #else
- error=L_DecompressVGAScreen(infile, Width, Height, Xorigin,Yorigin);
- #endif
- }
- if( (time>1) )
- L_SleepKey(time);
- }
- }
- else if(video==TARGAOLD)
- {
- error=L_DecompressTARGAScreen(infile,0,0,Xorigin,Yorigin);
- if( (time>1) )
- L_SleepKey(time);
- }
- }
- time=0;
- infile[0]='\0';
- }/*end while reading*/
- L_SetVideoMode(mode,page);
- exit(0);
- }/*if*/
- else
- {
- printf("Error: could not open macro file %s\n",pathname);
- exit(0);
- }
- }
- else
- {
- for (i = 2; i<=argc; i++)
- {
- strupr(argv[i]);
- if(argv[i][0]=='/')
- if(get_value(&argv[i][1])==BAD_COMMAND)
- {
- printf("\n LEADTOOLS DOS EVAL copy V 2.2");
- printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
- printf(" 8701 Mallard Creek Rd.\n");
- printf(" Charlotte NC 28262\n");
- printf(" tel# (704)549-5532\n");
- printf("\nDOS - File to screen software deompression utility Version 3.4\n");
- printf("\nThis version has a limit of image width not to exceed 1500 pixels.\n");
- L_SleepKey(2);
- printf("USAGE: LSHOW <source file> [/option1] [/option2] [/option3] [/option4]\n");
- printf(" [/option5] [/option6]\n\n");
- printf("<source file> is any LEAD, JFIF, or JTIF compressed file formats\n");
- printf("<source file> is any LEAD, JFIF, or JTIF compressed file formats\n");
- printf(" or TGA, TIFF, or BMP file formats\n");
-
- #ifdef TARGA
- printf("[option1] /TA for TARGA16, TARGA24, or TARGA32\n");
- #else
- printf("[option1] /TA for TARGA+16, TARGA+32, TARGA+64\n");
- #endif
- printf(" or /V320 display to FAST SUPER VGA 320X200\n");
- printf(" /V640 display to FAST SUPER VGA 640X480\n");
- printf(" /V800 display to FAST SUPER VGA 800X600\n");
- printf(" /V1024 display to FAST SUPER VGA 1024X768\n");
- printf("[option2] /W# the New Width of the image displayed on the screen\n");
- printf("[option3] /H# the New Height of the image displayed on the screen\n");
- printf("[option4] /T# number of seconds to keep image displayed on the screen\n");
- printf("[option5] /X# the X (horizontal) position of the image displayed on the screen\n");
- printf("[option6] /Y# the Y (vertical) position of the image displayed on the screen\n\n");
- printf("EXAMPLE LSHOW *.* /W300 /H200 /T4 /X20 /Y20\n");
- printf("Will display all image files to the VGA/SuperVGA screen at the best resolution\nfor the selected image file\n\n\n");
- printf("BAD COMMAND %s\n",argv[i-1]);
- exit(0);
- }/* end if getvalue*/
- }/*end for*/
-
-
-
-
-
-
- result = _dos_findfirst(argv[1], 0 , &file);
- if (result) /* if result has any value rather that 0 then */
- printf("LSHOW: no such file %s\n",argv[1]);
- else
- while(!result) /* Stop when _dos_findnext returns */
- {
- strcpy(infile, pathname);
- strcat(infile, file.name);
- if(video==VGA)
- {
- L_GetVideoDeviceBits(&device_bits);
- if (L_FileInfo(infile, &FileInformation)==SUCCESS)
- {
- if( FileInformation.Format == FILE_TGA)
- {
-
- #if !defined(FOR_386)
- if(FileInformation.BitsPerPixel > 8)
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- L_SetVideoMode(mode,page);
- puts("Error: cannot load FIXED.DAT file.\n");
- putch(7);
- exit(0);
- }
- #endif
-
- error=L_ShowTGAScreen(infile,Width,Height,Xorigin,Yorigin);
-
- #if !defined(FOR_386)
- if (FileInformation.BitsPerPixel > 8 && device_bits == 8 )
- L_FreeRGBFixedPalette();
- #endif
- }
- else if( FileInformation.Format == FILE_TIF)
- {
- #if !defined(FOR_386)
- if(FileInformation.BitsPerPixel > 8)
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- L_SetVideoMode(mode,page);
- puts("Error: cannot load FIXED.DAT file.\n");
- putch(7);
- exit(0);
- }
- #endif
-
- error=L_ShowTIFScreen(infile,Width,Height,Xorigin,Yorigin);
-
- #if !defined(FOR_386)
- if (FileInformation.BitsPerPixel > 8 && device_bits == 8 )
- L_FreeRGBFixedPalette();
- #endif
-
- }
- else if( (FileInformation.Format == FILE_BMP) || (FileInformation.Format == FILE_OS2) )
- {
- #if !defined(FOR_386)
- if(FileInformation.BitsPerPixel > 8)
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- L_SetVideoMode(mode,page);
- puts("Error: cannot load FIXED.DAT file.\n");
- putch(7);
- exit(0);
- }
- #endif
-
- error=L_ShowBMPScreen(infile,Width,Height,Xorigin,Yorigin);
-
- #if !defined(FOR_386)
- if (FileInformation.BitsPerPixel > 8 && device_bits == 8 )
- L_FreeRGBFixedPalette();
- #endif
- }
- else if( FileInformation.Format == FILE_PCX)
- {
- #if !defined(FOR_386)
- if(FileInformation.BitsPerPixel > 8)
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- L_SetVideoMode(mode,page);
- puts("Error: cannot load FIXED.DAT file.\n");
- putch(7);
- exit(0);
- }
- #endif
-
- error=L_ShowPCXScreen(infile,Width,Height,Xorigin,Yorigin);
-
- #if !defined(FOR_386)
- if (FileInformation.BitsPerPixel > 8 && device_bits == 8 )
- L_FreeRGBFixedPalette();
- #endif
-
- }
- else if( FileInformation.Format == FILE_GIF)
- {
- error=L_ShowGIFScreen(infile,Width,Height,Xorigin,Yorigin);
- }
- else if( (FileInformation.Format == FILE_CMP) || (FileInformation.Format == FILE_JTIF)
- || ( FileInformation.Format == FILE_JFIF) )
- {
- #if !defined(FOR_386)
- error=L_DecompressVGAScreenFP(infile, Width, Height, Xorigin,Yorigin);
- #else
- error=L_DecompressVGAScreen(infile, Width, Height, Xorigin,Yorigin);
- #endif
- }
- if( (time>1) )
- L_SleepKey(time);
- }
- }
- else if(video==TARGAOLD)
- {
- printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
- printf(" 8701 Mallard Creek Rd.\n");
- printf(" Charlotte NC 28262\n");
- printf(" tel# (704)549-5532\n");
- printf("\nDOS - File to screen software deompression utility Version 3.4\n");
- #ifdef TARGA
- printf("Viewing image file %s to TARGA screen",file.name);
-
- #else
- printf("Viewing image file %s to TARGA+ screen",file.name);
- #endif
- error=L_DecompressTARGAScreen(infile,0,0,Xorigin,Yorigin);
-
- if((time >1))
- L_SleepKey(time);
- else if (error != SUCCESS)
- {
- printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
- printf(" 8701 Mallard Creek Rd.\n");
- printf(" Charlotte NC 28262\n");
- printf(" tel# (704)549-5532\n");
- printf("\nDOS - File to screen software deompression utility Version 3.4\n");
- printf("ERROR %d VIEWING IMAGE FILE %s\n",error,file.name);
- L_SleepKey(2);
- }
- }
- result = _dos_findnext(&file);
- }
- L_SetVideoMode(mode,page);
- }/*else*/
- exit(0);
- }
-
-
-
- get_value(char *string)
- {
- int ret=OK;
-
- if (string[0] == 'X')
- {
- Xorigin = atoi(string+1);
- if (Xorigin < 0 || Xorigin > 1024)
- return(BAD_COMMAND);
- else
- return(ret);
- }
-
- if (string[0] == 'Y')
- {
- Yorigin = atoi(string+1);
- if (Yorigin < 0 || Yorigin > 1024)
- return(BAD_COMMAND);
- else
- return(ret);
- }
-
- if (string[0] == 'T' && string[1] != 'A')
- {
- time = atoi(string+1);
- if (time < 0)
- return(BAD_COMMAND);
- else
- return(ret);
- }
-
- if (string[0] == 'w' || string[0] == 'W')
- {
- Width = atoi(string+1);
- if (Width < 0)
- return(BAD_COMMAND);
- else
- return(ret);
- }
-
- if (string[0] == 'h' || string[0] == 'H')
- {
- Height = atoi(string+1);
- if (Height < 0)
- return(BAD_COMMAND);
- else
- return(ret);
- }
-
- if (string[0] == 'T' && string[1] == 'A')
- {
- video=TARGAOLD;
- if(L_TARGAInit()==0)
- {
- #ifdef TARGA
- printf("TARGA Initialization error\n\n");
- #else
- printf("TARGA+ Initialization error\n\n");
- #endif
- exit(0);
- }
- }
-
- if(string[0] == 'V')
- {
- video=VGA;
- if(strstr(string,"V320"))
- {
- L_SetVideoMode(mode,page);
- L_SetVGASize(SIZE_320x200);
- }
- else if(strstr(string,"V640"))
- {
- L_SetVideoMode(mode,page);
- L_SetVGASize(SIZE_640x480);
- }
- else if(strstr(string,"V800"))
- {
- L_SetVideoMode(mode,page);
- L_SetVGASize(SIZE_800x600);
- }
- else if(strstr(string,"V1024"))
- {
- L_SetVideoMode(mode,page);
- L_SetVGASize(SIZE_1024x768);
- }
- }
- return(ret);
- }
-
-
-
- get_pathname(char in[], char pathname[])
- {
- int i;
-
- strcpy(pathname, in);
- for (i = strlen(in)-1; i >= 0; i--)
- {
- if( (in[i] == '\\') || (in[i] == ':') )
- break;
- }
-
- if (i == 0)
- pathname[0] = 0;
- else
- pathname[i+1] = 0;
- }
-
-
- getfilename(char * name)
- {
- int i=0;
-
- while(name[i]!=' ')
- {
- i++;
- }
- name[i]=='\0';
- }